package com.cskaoyan.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 杨杰
 * @version V1.0
 * @Package com.cskaoyan.bean
 * @date 2020/12/8 12:38
 * @Copyright © 暂时还没有
 * @Desciption 工具类，用于获取Date格式的当前时间
 */
@Component
public class TimeTool {

    @JsonFormat(pattern = "yy-MM-dd HH:mm:ss",timezone = "GMT+8")
    static Date date = new Date();
    public static Date getCurrentTime(){
        
        long time = date.getTime()+1000*60*60*24;
        SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss");

        String stringTime = sdf.format(time);

        Date parse = null;
        try {
            parse = sdf.parse(stringTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
}
